package org.letva.toink.blog.service;

import org.letva.toink.blog.model.Comment;
import org.letva.toink.blog.model.Post;
import org.letva.toink.blog.model.User;

import java.util.List;

/**
 * BlogService is the main service in blog application. All the service methods,
 * and they are separated in several "groups":
 * <ol>
 *  <li>
 *      User login/registration
 *  </li>
 *  <li>
 *      Post CRUD operations and retrieve posts operations.
 *  </li>
 *  <li>
 *      Comment CRUD operations and retrieve comments operations.
 *  </li>
 * </ol>
 */
public interface BlogService {

    // ---------------------------- User registration/login methods
    void login();
    void logout();
    User register(User user);
    boolean isLoggedIn();
    
    // --------------------------- Post CRUD operations
    void addPost(Post post);
    Post getPost(Long postId);
    void updatePost(Post post);
    void deletePost(Post post);

    // ---------------------------- Retrieve Posts
    List<Post> getPosts(User user, int fromCount, int toCount);
    List<Post> getPosts(int fromCount, int toCount);
    List<Post> getNewestPosts(int count);
    List<Post> getNewestPosts(User user, int count);

    // --------------------------- Comment CRUD operations
    void addComment(Long postId, Comment comment);
    void addComment(Post post, Comment comment);
    Comment getComment(Long commentId);
    void updateComment(Comment comment);
    void deleteComment(Comment comment);

    // ---------------------------- Retrieve Comments
    List<Comment> getPostComments(Long postId, int fromCount, int toCount);
    List<Comment> getPostComments(Post post, int fromCount, int toCount);
    List<Comment> getUserComments(Long userId, int fromCount, int toCount);
    List<Comment> getUserComments(User user, int fromCount, int toCount);


    
}
